package com.zcg.gasmanager.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.zcg.gasmanager.dao.AdminDao;
import com.zcg.gasmanager.model.Admin;
import com.zcg.gasmanager.utils.HibernateUtil;

@Component("adminDao")
public class AdminDaoImpl implements AdminDao {

	private HibernateTemplate hibernateTemplate;

	@Override
	public boolean load(Admin admin) throws RuntimeException{
		List<Admin> admins = hibernateTemplate
				.find("from Admin a where a.name = ? and a.password = ?",new Object[]{admin.getName(),admin.getPassword()});

		if (admins != null && admins.size() > 0) {
			return true;
		}
		return false;
	}

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

}
